using System;
using System.Collections.Generic;
using System.Text;
using System.Resources;
using System.Drawing;
using System.IO;
using System.Collections;

namespace OsdmSoftware.CommonLibrary
{
    public class ImageFolderReader: IResourceReader
    {
        Dictionary<string, Image> dict = new Dictionary<string, Image>();

        public ImageFolderReader(string folderName)
        {
            string[] files = Directory.GetFiles(folderName);
            foreach (string s in files)
            {
                dict.Add(Path.GetFileNameWithoutExtension(s), new Bitmap(s));
            }
        }

        public void Close()
        {

        }

        public System.Collections.IDictionaryEnumerator GetEnumerator()
        {
            return ((IDictionary) dict).GetEnumerator();
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return ((IEnumerable) dict).GetEnumerator();
        }

        public void Dispose()
        {
            foreach (Image im in dict.Values)
                im.Dispose();

            dict = null;
        }
    }
}
